<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@include file="common.jsp"%>

<%  String msg = request.getParameter("message");%> 
<html>
    <head>
        <title>
            Dành cho người quản trị website
        </title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <script language="JavaScript">
            function checkinput(){
                if(document.form1.username.value==""){
                    alert("Xin vui long nhap username");
                    document.form1.username.focus();
                    return false;
                }
                if(document.form1.password.value=="" ){
                    alert("Xin vui long nhap password");
                    document.form1.password.focus();
                    return false;
                }
                return true;
            }
        </script>
        <%
            String userid = getVal((String) session.getValue("userid"), "");
            if (!(userid.equals("") || userid.equals("0") || userid.equals("-1") || userid.equals("-2"))) {
                response.sendRedirect("AdminPage.jsp");
            }
            String err = "Xin vui lòng nhập password. Username và Password mặc định là: admin, admin";
            if (userid.equals("0")) {
                err = "<font color=\"#FF0000\">Sai password,Xin vui lòng nhập password</font>";
            }
            if (userid.equals("-1")) {
                err = "<font color=\"#FF0000\">Sai username,Xin vui lòng nhập username</font>";
            }
            if (userid.equals("-2")) {
                err = "<font color=\"#FF0000\">Loi he thong, Xin vui lòng thử lại</font>";
            }

        %>
        <div>
        <form action="LoginServlet" name=form1 method=post onSubmit="return checkinput();">
            <table align=center>
                <tr>
                    <td colspan="2" height="19">
                        <h4><b><font color="#FF0000">
                                    <font color="#0000CC">Nhân viên quản lý</font>
                                </font></b></h4><hr>
                    </td>
                </tr><tr>
                    <td colspan=2 height="19">
                        <div align="left"><%=err%></div>
                    </td>
                </tr>
                <tr>
                    <td height="19">
                        <div align="left">Username</div>
                    </td>
                    <td height="19">
                        <div align="left">
                            <input type="text" name="username"
                                   size="30" maxlength="50" class=textbox>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td height="31">
                        <div align="left">Password</div>
                    </td>
                    <td height="31">
                        <div align="left">
                            <input type="password" name="password"
                                   size="30" maxlength="50" class=textbox>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td >&nbsp;</td>
                    <td>&nbsp;</td>
                </tr><tr>
                    <td ></td>
                    <td ><input type=submit value="Đăng nhập">
                        &nbsp; <input type=reset value="Hủy"></td>
                </tr>
            </table>
        </form>
        </div>
        <%    if ((msg != null) && (msg.equals("0"))) {%>   

        <SCRIPT language=JavaScript> 
            alert ("invalid. Nhap lai!");       
        </SCRIPT> 

        <p align="center"></p>  
        <%}%>      
    </body>
</html>